#!/bin/bash

echo "🚀 Java后端开发演示项目"
echo "================================"

# 检查Java环境
if ! command -v java &> /dev/null; then
    echo "❌ 错误：未找到Java环境，请先安装JDK"
    exit 1
fi

if ! command -v javac &> /dev/null; then
    echo "❌ 错误：未找到Java编译器，请先安装JDK"
    exit 1
fi

echo "✅ Java环境检查通过"
echo "Java版本："
java -version

echo ""
echo "📦 编译项目..."
javac -cp ".:src/main/java" src/main/java/com/jlb/demo/JavaBackendDemo.java

if [ $? -eq 0 ]; then
    echo "✅ 编译成功！"
    echo ""
    echo "🎯 运行演示程序..."
    echo "================================"
    java -cp ".:src/main/java" com.jlb.demo.JavaBackendDemo
else
    echo "❌ 编译失败，请检查代码"
    exit 1
fi 